Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data Stores: Migrate Analyzer store to createReduxStore() #74414

Merged
merged 2 commits into from
Mar 15, 2023

Conversation

tyxla
Copy link
Member

@tyxla tyxla commented Mar 14, 2023

Proposed Changes

This PR migrates the Analyzer store to use createReduxStore() and register() instead of registerStore().

Part of #74399. A follow-up to #73890.

Testing Instructions

  • The only step that uses this store is not currently enabled, so we have to manually enable it with a feature flag.
  • Navigate to /setup/site-setup/importLight?siteSlug=YOURSITE&flags=onboarding/import-light where YOURSITE is the slug of one of your sites.
  • If you land on the goals step, check the checkbox that you want to import your content into your site and push the button to continue forward. Retry the step above.
  • Verify import process still works well.

Pre-merge Checklist

  • Has the general commit checklist been followed? (PCYsg-hS-p2)
  • Have you written new tests for your changes?
  • Have you tested the feature in Simple (P9HQHe-k8-p2), Atomic (P9HQHe-jW-p2), and self-hosted Jetpack sites (PCYsg-g6b-p2)?
  • Have you checked for TypeScript, React or other console errors?
  • Have you used memoizing on expensive computations? More info in Memoizing with create-selector and Using memoizing selectors and Our Approach to Data
  • Have we added the "[Status] String Freeze" label as soon as any new strings were ready for translation (p4TIVU-5Jq-p2)?
  • For changes affecting Jetpack: Have we added the "[Status] Needs Privacy Updates" label if this pull request changes what data or activity we track or use (p4TIVU-ajp-p2)?

@tyxla tyxla added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it Framework [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. Import Stepper Data-Store Light Importer labels Mar 14, 2023
@tyxla tyxla requested review from bogiii and a team March 14, 2023 13:10
@tyxla tyxla self-assigned this Mar 14, 2023
@github-actions
Copy link

github-actions bot commented Mar 14, 2023

@matticbot
Copy link
Contributor

matticbot commented Mar 14, 2023

Here is how your PR affects size of JS and CSS bundles shipped to the user's browser:

App Entrypoints (~324 bytes removed 📉 [gzipped])

name           parsed_size           gzip_size
entry-stepper      -1028 B  (-0.0%)     -324 B  (-0.0%)

Common code that is always downloaded and parsed every time the app is loaded, no matter which route is used.

Sections (~109 bytes added 📈 [gzipped])

name             parsed_size           gzip_size
site-setup-flow      +1203 B  (+0.1%)     +430 B  (+0.1%)
sites-dashboard      -1028 B  (-0.2%)     -321 B  (-0.2%)
settings             -1028 B  (-0.1%)     -321 B  (-0.1%)
hosting              -1028 B  (-0.1%)     -321 B  (-0.1%)
home                 -1028 B  (-0.1%)     -321 B  (-0.1%)

Sections contain code specific for a given set of routes. Is downloaded and parsed only when a particular route is navigated to.

Async-loaded Components (~321 bytes removed 📉 [gzipped])

name               parsed_size           gzip_size
async-load-design      -1028 B  (-0.0%)     -321 B  (-0.1%)

React components that are loaded lazily, when a certain part of UI is displayed for the first time.

Legend

What is parsed and gzip size?

Parsed Size: Uncompressed size of the JS and CSS files. This much code needs to be parsed and stored in memory.
Gzip Size: Compressed size of the JS and CSS files. This much data needs to be downloaded over network.

Generated by performance advisor bot at iscalypsofastyet.com.

Copy link
Contributor

@flootr flootr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Appears to be working well 🚀

@@ -26,4 +26,4 @@ export const USER_STORE = User.register( {

export const AUTOMATED_ELIGIBILITY_STORE = AutomatedTransferEligibility.register();

export const ANALYZER_STORE = Analyzer.register();
export const ANALYZER_STORE = Analyzer.store;
Copy link
Contributor

@noahtallen noahtallen Mar 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

General thought for all Automattic data stores -- instead of this, should we just export the store object as Analyzer?

Then, when we're using anything in automattic/data-stores, it becomes simpler to use:

// or export it as analyzerStore, which is a bit clearer and follows our naming conventions
import { Analyzer } from '@automattic/data-stires';

useSelect( select => select( Analyzer ) )

(potentially avoiding the need to re-export the store from client/landing/stepper/stores too)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think for some stores we export additional modules and types, so it might be necessary to export some more on top of the store. For example:

export { SiteGoal, SiteIntent } from './constants';
export * as utils from './utils';
export * from './types';

Those are then re-exported by the @automattic/data-stores package and reused somewhere.

I'd suggest approaching those in another PR, since they might require additional work, and I don't see that as something related to refactoring to createReduxStore().

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed the store export indirection in 1ce6df9

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough! 👍

Copy link
Contributor

@bogiii bogiii left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! 🚢

@tyxla tyxla merged commit 92730aa into trunk Mar 15, 2023
@tyxla tyxla deleted the migrate/analyzer-store-create-redux-store branch March 15, 2023 11:18
@github-actions github-actions bot removed the [Status] Needs Review The PR is ready for review. This also triggers e2e canary tests and wp-desktop tests automatically. label Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Data-Store Framework Import Light Importer Stepper [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants